package com.hnd.springframework.beans.factory.support;

import com.hnd.springframework.beans.factory.BeanFactory;
import com.hnd.springframework.beans.factory.config.BeanDefinition;

/**
 * 定义获取bean的模板
 */
public abstract class AbstractBeanFactory implements BeanFactory {
    @Override
    public Object getBean(String beanName) {
        return getBean(beanName, null);
    }

    @Override
    public Object getBean(String beanName, Object... args) {
        BeanDefinition beanDefinition = getBeanDefinition(beanName);
        return createBean(beanName, beanDefinition, args);
    }

    public abstract BeanDefinition getBeanDefinition(String beanName);

    public abstract Object createBean(String beanName, BeanDefinition beanDefinition, Object... args);
}
